<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>支付号充值汇总</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">

        <div lay-filter="listSearch" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">


                <div class="layui-inline">
                    <input type="number" name="chargefrom" placeholder="支付号ID" autocomplete="off" class="layui-input">
                </div>

                <div class="layui-inline">
                    <input type="text" id="dayStart" name="start_date" placeholder="报表开始日期" autocomplete="off" class="layui-input">
                </div>

                <div class="layui-inline">
                    <input type="text" id="dayEnd" name="end_date" placeholder="报表结束日期" autocomplete="off" class="layui-input">
                </div>

                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-list-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                    <button type="button" class="layui-btn layui-btn-primary" lay-submit lay-filter="LAY-reset">重置</button>
                </div>

                <span style="margin-left:10px;">总金额：<span id="allMoney">0</span></span>

            </div>
        </div>

        <div class="layui-card-body">

            <table id="LAY-list-manage" lay-filter="LAY-list-manage"></table>

        </div>
    </div>
</div>

<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.use('laydate', function () {
        var $ = layui.$;
        var laydate = layui.laydate;

        var nowTime = new Date().valueOf();
        var start = laydate.render({
            elem: '#dayStart',
            type: 'date',
            max: nowTime,
            done: function (value, date) {
                endMax = end.config.max;
                end.config.min = date;
                end.config.min.month = date.month - 1;
            }
        });
        var end = laydate.render({
            elem: '#dayEnd',
            type: 'date',
            max: nowTime,
            done: function (value, date) {
                if ($.trim(value) == '') {
                    var curDate = new Date();
                    date = {
                        'date': curDate.getDate(),
                        'month': curDate.getMonth() + 1,
                        'year': curDate.getFullYear()
                    };
                }
                start.config.max = date;
                start.config.max.month = date.month - 1;
            }
        });
    });

    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','table','admin'], function(){
        var $ = layui.$
            ,form = layui.form
            ,admin = layui.admin
            ,table = layui.table;

        //监听搜索
        form.on('submit(LAY-list-front-search)', function(data){
            var field = data.field;

            //执行重载
            table.reload('LAY-list-manage', {
                where: field
                ,page: {
                    curr: 1  // 将页码重置为第一页
                }
            });
        });

        form.on('submit(LAY-reset)', function(data){
            form.val("listSearch", {
                "chargefrom": "",
                "start_date": "",
                "end_date": "",
            });
            form.render();
            table.reload('LAY-list-manage', {
                where: {"chargefrom": "","start_date": "","end_date":""}
                ,page: {
                    curr: 1  // 将页码重置为第一页
                }
            });
        });

        table.render({
            elem: '#LAY-list-manage'
            , url: "{:url('Payment/list_data')}" //模拟接口
            , response: {
                statusCode: 1 //规定成功的状态码，本来是：0，现在统一改为1
            }
            , page: true //开启分页
            , limit: 20
            , cols: [[
                {field: 'chargefrom', width: 100, title: '支付号ID',align: 'center'}
                , {field: 'title', title: '支付号名称',align: 'center'}
                , {field: 'recharged_num', title: '已支付笔数',align: 'center'}
                , {field: 'unpaid_num', title: '未支付笔数' ,align: 'center'}
                , {field: 'money', title: '充值金额' ,align: 'center'}
                , {field: 'create_date', title: '报表日期',align: 'center' }
            ]]
            ,text: '对不起，加载出现异常！'
            ,done: function(res, curr, count){
                $('#allMoney').html(res.totalRow.total_money);
            }
        });

    });
</script>
</body>
</html>